import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author yan
 * @date 2025/8/2
 */
public class ti3487 {
    class Solution {
        public int maxSum(int[] nums) {
            int n = nums.length;
            if(n<=1) {
                return nums[0];
            }
            int max =0;
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    if(nums[i]==nums[j]){
                        nums[j]=0;
                    }
                }
            }
            for(int i=0;i<n-1;i++){
                for(int j=0;j<n-i-1;j++){
                    if(nums[j]>nums[j+1]){
                        int temp = nums[j];
                        nums[j] = nums[j+1];
                        nums[j+1] = temp;
                    }
                }
            }
            int sum=0;
            for(int i=0;i<n;i++){
                if(nums[i]>0) {
                    sum += nums[i];
                    if (sum > max)
                        max = sum;
                }
            }
            return max;
        }
    }
    public static void main(String[] args) {

    }
}
